<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>

    </style>
</head>

<body>
    <input type="text" placeholder="手机">
    <script>
        var text = document.querySelector('input');
        //获得焦点事件
        text.onfocus = function () {
            console.log('得到了焦点');
            if (text.placeholder === '手机') {
                text.placeholder = '';
            }
            this.style.color = '#333';
        }
        //失去焦点
        text.onblur = function () {
            console.log('失去了焦点');
            if (text.placeholder === '') {
                text.placeholder = '手机';
            }
            this.style.color = '#999';
        }
    </script>
</body>

</html>